﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace ChartSharp
{
    public class AxisRange : ChartParam
    {
        protected IEnumerable<IEnumerable<string>> _labels;

        public override string Name
        {
            get { return "chxl"; }
        }

        public override string Data
        {
            get
            {
                StringBuilder builder = new StringBuilder();

                if (_labels != null)
                {
                    int index = 0;

                    _labels.ToList().ForEach((labelSet) =>
                    {
                        builder.Append((index++).ToString());
                        builder.Append(",");

                        labelSet.ToList().ForEach((label) =>
                        {
                            builder.Append(label);
                            builder.Append("|");
                        });
                    });

                    if (builder.Length > 0)
                    {
                        builder.Length--;
                    }
                }

                return builder.ToString();
            }
        }

        public AxisRange(IEnumerable<IEnumerable<string>> labels)
        {
            _labels = labels;
        }
    }
}
